#include<bits/stdc++.h>

using namespace std;
//25!末尾刚好是6个0 （整数的素因子分解 5的指数)
typedef long long ll;
ll MOD = 1e6;
ll n, s;

#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n;
    if (n > 24)n = 24;
    s = 0;
    for (int i = 1; i <= n; i++) {
        ll p = 1;
        for (int j = 2; j <= i; j++) {
            p = (p * j) % MOD;
        }
        s = (s + p) % MOD;
    }
    cout << s;
    return 0;
}